package com.jumi.microservice.common.base.dto;


import com.jumi.microservice.common.constant.ResultEnum;

import java.io.Serializable;

/**
 * - - - - - - - - - - - - - - -
 * 分页返回数据
 *
 * @author liuz
 * @date 2020/7/21 11:10
 * ToDoSomeThing
 * - - - - - - - - - - - - - - -
 */
public class BasePageResponse<T> implements Serializable {

    /**
     * 状态码
     */
    private int code;

    /**
     * 返回信息
     */
    private String message;

    /**
     * 数据列表
     */
    private T rows;

    /**
     * 总数
     */
    private Long total;

    /**
     * 总页数
     */
    private Long pageCount;

    public BasePageResponse() {
        this.code = ResultEnum.SUCCESS.getCode();
        this.message = ResultEnum.SUCCESS.getMessage();
    }

    public BasePageResponse(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public static <T> ResponseResult<T> success(T data) {
        return new ResponseResult<T>().setData(data);
    }

    public int getCode() {
        return code;
    }

    public BasePageResponse<T> setCode(int code) {
        this.code = code;
        return this;
    }

    public String getMessage() {
        return message;
    }

    public BasePageResponse<T> setMessage(String message) {
        this.message = message;
        return this;
    }

    public T getRows() {
        return rows;
    }

    public BasePageResponse<T> setRows(T rows) {
        this.rows = rows;
        return this;
    }

    public Long getTotal() {
        return total;
    }

    public BasePageResponse<T> setTotal(Long total) {
        this.total = total;
        return this;
    }

    public Long getPageCount() {
        return pageCount;
    }

    public BasePageResponse<T> setPageCount(Long pageCount) {
        this.pageCount = pageCount;
        return this;
    }
}
